From a115f599507c1e8d33ed0c98298b97e1348d3d70 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 9 Apr 2018 00:35:32 +0200 Subject: [PATCH] drawcontext: Add a surface_resized() vfunc Call this vfunc whenever the surface's size has changed. --- gdk/gdkdrawcontext.c | 20 ++++++++++++++++++++ gdk/gdkdrawcontextprivate.h | 3 +++ gdk/gdksurface.c | 5 +++++ 3 files changed, 28 insertions(+) diff --git a/gdk/gdkdrawcontext.c b/gdk/gdkdrawcontext.c index 0f020f93e3..33324f44e3 100644 --- a/gdk/gdkdrawcontext.c +++ b/gdk/gdkdrawcontext.c @@ -67,6 +67,11 @@ static GParamSpec *pspecs[LAST_PROP] = { NULL, }; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrawContext, gdk_draw_context, G_TYPE_OBJECT) +static void +gdk_draw_context_default_surface_resized (GdkDrawContext *context) +{ +} + static void gdk_draw_context_dispose (GObject *gobject) { @@ -137,6 +142,8 @@ gdk_draw_context_class_init (GdkDrawContextClass *klass) gobject_class->get_property = gdk_draw_context_get_property; gobject_class->dispose = gdk_draw_context_dispose; + klass->surface_resized = gdk_draw_context_default_surface_resized; + /** * GdkDrawContext:display: * @@ -247,6 +254,19 @@ gdk_draw_context_end_frame (GdkDrawContext *context, priv->is_drawing = FALSE; } +/*< private > + * gdk_draw_context_surface_resized: + * @context: a #GdkDrawContext + * + * Called by the #GdkSurface the @context belongs to when the size of the surface + * changes. + */ +void +gdk_draw_context_surface_resized (GdkDrawContext *context) +{ + GDK_DRAW_CONTEXT_GET_CLASS (context)->surface_resized (context); +} + /** * gdk_draw_context_get_display: * @context: a #GdkDrawContext diff --git a/gdk/gdkdrawcontextprivate.h b/gdk/gdkdrawcontextprivate.h index 0223787a1d..33c4b72546 100644 --- a/gdk/gdkdrawcontextprivate.h +++ b/gdk/gdkdrawcontextprivate.h @@ -45,6 +45,7 @@ struct _GdkDrawContextClass void (* end_frame) (GdkDrawContext *context, cairo_region_t *painted, cairo_region_t *damage); + void (* surface_resized) (GdkDrawContext *context); }; gboolean gdk_draw_context_is_drawing (GdkDrawContext *context); @@ -54,6 +55,8 @@ void gdk_draw_context_end_frame (GdkDrawContext cairo_region_t *painted, cairo_region_t *damage); +void gdk_draw_context_surface_resized (GdkDrawContext *context); + G_END_DECLS #endif /* __GDK__DRAW_CONTEXT_PRIVATE__ */ diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index bc12fd589d..d9bbcb7534 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -622,6 +622,11 @@ gdk_surface_append_old_updated_area (GdkSurface *surface, void _gdk_surface_update_size (GdkSurface *surface) { + GSList *l; + + for (l = surface->draw_contexts; l; l = l->next) + gdk_draw_context_surface_resized (l->data); + gdk_surface_clear_old_updated_area (surface); recompute_visible_regions (surface, FALSE); } -- 2.30.2